#ifndef NODE_H
#define NODE_H

#include <vector>
#include "SourceTerminal.h"
#include "llvm/IRBuilder.h"

class NodeContainer;

class Node {
  
 public:
  
  Node(NodeContainer* parent);
  virtual ~Node();
  
  virtual bool isIO();
  virtual void process (llvm::IRBuilder<> *builder) =0;
  
  //this is public for Structures and Diagrams and stuff
  SourceTerminal* addSource();
  virtual Terminal* addSink();
  
  void propagateValues();
  void valueAssigned();
  
  void checkForPromotion();

  void connectSourceTo(Node* target, int sourceIndex, int sinkIndex);

  
 protected:

  //not owned/primitive
  NodeContainer* parent;
  int unassignedSinks;
  
  //ownership
  std::vector<Terminal*> terminals;

  //nonownership
  std::vector<SourceTerminal*> sources;
  
};

#endif
